package org.springboot.jpetstore.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.UUID;

/**
 * Created by Robin on 2017/11/29.
 */
@Controller
@RequestMapping("/login")
public class LoginAction {

    //Session共享，生成Session并自动存入redis
    @RequestMapping("/uid")
    String uid(HttpSession session) {
        UUID uid = (UUID) session.getAttribute("uid");
        if (uid == null) {
            uid = UUID.randomUUID();
        }
        session.setAttribute("uid", uid);
        return "SUCCESS";
    }
}
